﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using PloobsEngine.Cameras;
using PloobsEngine.SceneControl;

namespace PloobsEngine.Physics
{
    public delegate bool CullerConditionAvaliator<T, V>(T param1, V param2);

    public interface IPhysicWorld
    {
        bool isDebugDraw { get; set; }
        List<IPhysicObject> PhysicObjects { get; }        
        void DebugDrawn(GameTime gt, ICamera cam);
        void Update(GameTime gt);
        void AddObject(IPhysicObject obj);
        void RemoveObject(IPhysicObject obj);        
        void Serialize(System.Xml.XmlTextWriter textWriter);
        void DeSerialize(System.Xml.XmlNode node, EngineStuff engine);        
        SegmentInterceptInfo SegmentIntersect(Ray raio,SegmentInterceptMethod method,float maxDistance);
        List<IPhysicObject> DetectCollisions(IPhysicObject po);

        /// <summary>
        /// Get the objects near the object passed as parameter
        /// </summary>
        /// <param name="po"></param>
        /// <param name="distance"></param>
        /// <param name="CullerAvaliator"></param>
        /// <returns></returns>
        List<IPhysicObject> GetPhysicsObjectsInRange(IPhysicObject po, float distance,CullerConditionAvaliator<IPhysicObject, IObject> CullerAvaliator);
        
    }

    public enum SegmentInterceptMethod
    {
        ALL, NO_TRINAGLEMESH,ONLY_MOBILES,ONLY_STOPPEDS,ONLY_TRIANGLEMESH
    }
}
